package com.lineage.data.npc;

import com.lineage.config.ConfigOther;
import com.lineage.data.executor.NpcExecutor;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_NPCTalkReturn;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.william.daily_bonus;

public class Npc_dailybonus extends NpcExecutor {
  public static NpcExecutor get() {
    return new Npc_dailybonus();
  }
  
  public int type() {
    return 3;
  }
  
  public void talk(L1PcInstance pc, L1NpcInstance npc) {
    String type = "";
    if (pc.getQuest().get_step(8991) != 1) {
      type = "今日尚未签到";
    } else {
      type = String.valueOf(pc.getday());
    } 
    type = String.valueOf(pc.getday());
    pc.sendPackets((ServerBasePacket)new S_NPCTalkReturn(npc.getId(), "dailybonus", new String[] { type }));
  }
  
  public void action(L1PcInstance _pc, L1NpcInstance npc, String cmd, long amount) {
    try {
      if (cmd.equalsIgnoreCase("dailybonusok")) {
        if (_pc.getQuest().get_step(8991) > 0) {
          _pc.sendPackets((ServerBasePacket)new S_SystemMessage("今日已完成签到"));
          return;
        } 
        if (_pc.isGm()) {
          _pc.sendPackets((ServerBasePacket)new S_SystemMessage("你身分是GM，签到三小"));
          return;
        } 
        if (_pc.getInventory().getWeight240() >= 197) {
          _pc.sendPackets((ServerBasePacket)new S_ServerMessage(110));
          return;
        } 
        if (_pc.getInventory().getSize() >= 170) {
          _pc.sendPackets((ServerBasePacket)new S_SystemMessage("身上物品太多无法进行签到"));
          return;
        } 
        if (_pc.getday() == 7) {
          _pc.setday(0);
          _pc.sendPackets((ServerBasePacket)new S_SystemMessage("签到日已满，将会重新计算"));
          _pc.sendPackets((ServerBasePacket)new S_SystemMessage("请重新点我进行签到即可。"));
          return;
        } 
        if (_pc.getLevel() < ConfigOther.day_level) {
          _pc.sendPackets((ServerBasePacket)new S_SystemMessage("等级不足:[" + ConfigOther.day_level + "].无法签到"));
          return;
        } 
        if (_pc.getInventory().getSize() > 170) {
          _pc.sendPackets((ServerBasePacket)new S_ServerMessage(337, "身上空间"));
          return;
        } 
        _pc.setday(_pc.getday() + 1);
        daily_bonus.dailybonus(_pc);
      } 
    } catch (Exception exception) {}
  }
}
